package com.imedway.ihe.dtz.xds.client;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetRequestType;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetResponseType;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveDocumentSetRequestType.DocumentRequest;
import org.openehealth.ipf.commons.ihe.xds.iti43.Iti43PortType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import com.imedway.ihe.dd.properties.ItiAddressProps;
import com.imedway.ihe.dd.util.WebserviceUtil;
import com.imedway.ihe.dtz.xds.dao.Iti43Dao;
import com.imedway.ihe.dtz.xds.repository.Iti41Repository;

import lombok.extern.slf4j.Slf4j;

/**
 * @author dtz <br/>
 * @date 2024/7/4
 */
@Slf4j
@SpringBootTest
public class Iti43Client{
		
	static String serviceWsdl ="http://localhost:8080/services/iti43?wsdl";
	static String serviceNamespaceUri ="http://service.ihe.imedway.com/";
	static String serviceLocalPart = "Iti43PortTypeImplService";
	
	public Iti43PortType getClient() {
		ItiAddressProps itiAddressProps=new ItiAddressProps();
		itiAddressProps.setServiceLocalPart(serviceLocalPart);
		itiAddressProps.setServiceNamespaceUri(serviceNamespaceUri);
		Iti43PortType itiPortType = WebserviceUtil.buildWebService(Iti43PortType.class, serviceWsdl,itiAddressProps);
		return itiPortType;		
	};
	
	@Test
	public void findRetrievedDocument() throws SQLException {
        RetrieveDocumentSetRequestType body = new RetrieveDocumentSetRequestType();
        List<DocumentRequest> documentRequestLists = new ArrayList<DocumentRequest>();
		DocumentRequest documentRequest = new DocumentRequest();
		documentRequest.setDocumentUniqueId("2");
		documentRequestLists.add(documentRequest);
		body.getDocumentRequest().addAll(documentRequestLists);
		RetrieveDocumentSetResponseType retrieveDocumentSetResponseType= getClient().documentRepositoryRetrieveDocumentSet(body);
	    log.info(retrieveDocumentSetResponseType.getRegistryResponse().getStatus());
	}

}
